package com.bawei.park2302.repair

import com.bawei.lib_base.utils.utils.mvi.BaseViewModel
import com.bawei.lib_base.utils.utils.request.RequestType
import com.bawei.lib_base.utils.utils.utils.ApiService
import com.bawei.park2302.park.ParkIntent
import dagger.hilt.android.lifecycle.HiltViewModel
import javax.inject.Inject

@HiltViewModel
class RepairViewModel @Inject constructor(val apiService: ApiService) : BaseViewModel<RepairIntent>(){
    override fun handelIntent(it: RepairIntent) {
        when(it){
            is RepairIntent.repair -> httpRequest(apiService.repair())

            is RepairIntent.repairAdd -> httpRequest(apiService.repairAdd(mapToBody(it.repairBeanItem)))

            is RepairIntent.repairOrderNumber -> httpRequest(apiService.repairOrderNumber(it.orderNumber),RequestType.SEARCH)

            is RepairIntent.repairOrderSearch -> httpRequest(apiService.repairOrderSearch(it.repairName))

            is RepairIntent.repairDetail -> httpRequest(apiService.repairDetail(it.id),RequestType.DETAIL)

            is RepairIntent.repairOrders -> httpRequest(apiService.repairOrders(it.id,mapToBody(it.bean)),RequestType.SPACE)
        }
    }
}